#! /usr/bin/env python
"""
Author: Chip Chapin <cchapin@gmail.com>
For More Info: http://code.google.com/p/seq-to-qt/
Last Updated: 2010-02-05

File Sequence: A collection of files in a single directory where the filenames
consist of a common prefix and a numeric suffix.
  For example, MT0001.jpg, MT0002.jpg, MT0003.jpg ...

Chunking: Dividing a file sequence into shorter subsequences by moving some of
them into other directories.

I use this for dividing still image sequences into pieces that QuickTime
can handle.
"""
import seq_to_qt
import os

def usage(message=None):
    """Print usage message and exit."""
    if message:
        print message
    print "Usage: make_seq_chunks.py sequenceFile chunkSize"
    print (
"\nSequences have sequentially numbered file names like\n" +
"    Foo-001.jpg, Foo-002.jpg...\n" +
"sequenceFile -- Path to any file in the sequence.\n" +
"chunkSize -- Maximum number of sequence files to put in a folder.");
    sys.exit(2)

def main(argv):
    """Main Program"""
    if (len(argv) != 3):
        usage("Expected two arguments")  
    a_seq_file = os.path.abspath(argv[1])
    chunk_size = float(argv[2])
    
    if not os.path.isfile(a_seq_file):
        usage("'%s' is not a file." % a_seq_file)
    seq_to_qt.make_seq_chunks(a_seq_file, chunk_size)

if __name__ == "__main__":
    import sys
    main(sys.argv)
